package com.lansi.blegatewayconfig.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lansi.blegatewayconfig.bean.BleGatewayConfig;
import com.lansi.blegatewayconfig.mapper.BleGatewayConfigMapper;

@Service
public class BleGatewayConfigService implements IBleGatewayConfigService{
	@Resource
	private BleGatewayConfigMapper bleGatewayConfigMapper;
	public void registerBleGatewayConfig(BleGatewayConfig bleGatewayConfig) {
		
		bleGatewayConfigMapper.insertBleGatewayConfig(bleGatewayConfig);
	}

	public void delBleGatewayConfig(Integer[] ids) {
		
		bleGatewayConfigMapper.deleteBleGatewayConfig(ids);
	}

	public void delBleGatewayConfigById(Integer id) {
		
		bleGatewayConfigMapper.deleteBleGatewayConfigById(id);
	}

	public void updateBleGatewayConfig(Integer id, String deveui, String sn, Byte adr, Byte rfu, Byte dr, Byte mode,
			Byte smode, Byte power, Byte lostpoint, Byte selfadapt, Byte oneoff, Byte alreport, Short gps, Short hb,
			Short crc16) {
		
		BleGatewayConfig bleGatewayConfig = new BleGatewayConfig();
		bleGatewayConfig.setId(id);
		bleGatewayConfig.setDeveui(deveui);
		bleGatewayConfig.setSn(sn);
		bleGatewayConfig.setAdr(adr);
		bleGatewayConfig.setRfu(rfu);
		bleGatewayConfig.setDr(dr);
		bleGatewayConfig.setMode(mode);
		bleGatewayConfig.setSmode(smode);
		bleGatewayConfig.setPower(power);
		bleGatewayConfig.setLostpoint(lostpoint);
		bleGatewayConfig.setSelfadapt(selfadapt);
		bleGatewayConfig.setOneoff(oneoff);
		bleGatewayConfig.setAlreport(alreport);
		bleGatewayConfig.setGps(gps);
		bleGatewayConfig.setHb(hb);
		bleGatewayConfig.setCrc16(crc16);
		
		bleGatewayConfigMapper.updateBleGatewayConfig(bleGatewayConfig);
		
	}

	public List<BleGatewayConfig> getBleGatewayConfig(String deveui, String sn, Integer offset, Integer count) {
		
		return bleGatewayConfigMapper.selectBleGatewayConfig(deveui, sn, offset, count);
	}

	public BleGatewayConfig getBleGatewayConfigById(Integer id) {
		
		return bleGatewayConfigMapper.selectBleGatewayConfigById(id);
	}

	public BleGatewayConfig getBleGatewayConfigByDeveui(String deveui) {
		// TODO Auto-generated method stub
		return bleGatewayConfigMapper.selectBleGatewayConfigByDeveui(deveui);
	}

	public List<BleGatewayConfig> getBleGatewayConfigBySn(String sn) {
		// TODO Auto-generated method stub
		return bleGatewayConfigMapper.selectBleGatewayConfigBySn(sn);
	}

	public Integer getBleGatewayConfigcount(String deveui, String sn) {
		// TODO Auto-generated method stub
		return bleGatewayConfigMapper.selectBleGatewayConfigcount(deveui, sn);
	}

	public void updateAllBleGatewayConfig(String deveui, String sn, Byte adr, Byte rfu, Byte dr, Byte mode, Byte smode,
			Byte power, Byte lostpoint, Byte selfadapt, Byte oneoff, Byte alreport, Short gps, Short hb, Short crc16) {
		
		BleGatewayConfig bleGatewayConfig = new BleGatewayConfig();	
		
		bleGatewayConfig.setDeveui(deveui);
		bleGatewayConfig.setSn(sn);
		bleGatewayConfig.setAdr(adr);
		bleGatewayConfig.setRfu(rfu);
		bleGatewayConfig.setDr(dr);
		bleGatewayConfig.setMode(mode);
		bleGatewayConfig.setSmode(smode);
		bleGatewayConfig.setPower(power);
		bleGatewayConfig.setLostpoint(lostpoint);
		bleGatewayConfig.setSelfadapt(selfadapt);
		bleGatewayConfig.setOneoff(oneoff);
		bleGatewayConfig.setAlreport(alreport);
		bleGatewayConfig.setGps(gps);
		bleGatewayConfig.setHb(hb);
		bleGatewayConfig.setCrc16(crc16);		
		bleGatewayConfigMapper.updateAllBleGatewayConfig(bleGatewayConfig);
		
	}}
